#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>


int main()
{
    umask(0);
    int fd  = open("log.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
    if(fd < 0)
    {
        perror("open file erro");
        return 1;
    }
    const char* str = "hello world\n";
    write(fd, str, strlen(str));
    close(fd);
    return 0;
}

